<template>
  <q-page class="q-pa-md">
    <div class="q-pb-md text-h5">
      {{pageTitle}}
      <span class="text-subtitle1">{{ pageSubTitle }}</span>
    </div>
    <div class="q-pa-sm shadow-2 q-mb-md">
      <div class="q-gutter-sm">
        <q-btn  color="primary" icon="arrow_back" outline title="返回"  @click="detailNav.goBackToList" />
        <q-btn :disable="loadingState" :loading="loadingState" @click="loadModelData" color="primary" dense
          icon="refresh" outline title="刷新" v-if="isViewOrEditMode" />
      </div>
    </div>
    <!--错误提示-->
    <q-banner class="text-white bg-red q-my-sm" dense inline-actions v-if="serverErrorMessage">
      {{ serverErrorMessage }}
      <template v-slot:action>
        <q-btn @click="serverErrorMessage = ''" dense flat icon="close" size="sm" />
      </template>
    </q-banner>
    <!--内容主体-->
    <form-field-group :model-with-create-update="$d.form" model-id="id" title="主要信息">
      <div class="q-pa-sm">
        <div class="row q-col-gutter-sm">
          <div class="col-12 col-sm-6 col-md-4 col-lg-3">
            <span>工序编号</span>
            <easy-input v-model="$d.form.serialNumber" readonly></easy-input>
          </div>
          <div class="col-12 col-sm-6 col-md-4 col-lg-3">
            <span>工序名称</span>
            <easy-input v-model="$d.form.serialName" :readonly="isViewMode"/>
          </div>

          <div class="col-12 col-sm-6 col-md-4 col-lg-3">
            <span>工序系数</span>
            <easy-input v-model="$d.form.serialCoefficient" :readonly="isViewMode"/>
          </div>
        </div>
      </div>
    </form-field-group>
  </q-page>
</template>
<script lang="ts">
export default {
  name: 'LabelManagementStd'
}
</script>
<script lang="ts" setup>
import {reactive, ref} from 'vue'
import {useDetailHelper} from '@njt/foundation/hooks/detailHelper'
import {MhlbcLabelBasicProcess} from 'src/defs/labelManagement'
import {useTitleHelper} from '@njt/foundation/hooks/titleHelper'

const pageTitle = '贴标工序管理'
useTitleHelper(pageTitle)
// 数据加载/提交状态
let $d = reactive({
  form:{} as  MhlbcLabelBasicProcess,
})

let defFormDataForCreate={}
const serverErrorMessage = ref('')
const loadingState = ref(false)
// 加载数据
const loadModelData = function () {
  serverErrorMessage.value = ''
  loadingState.value = true
  $f.axios
    .get<MhlbcLabelBasicProcess>('/project/mhlbc/inv/inventory/get-label-basic-process-by-id/' + detailInfo.itemId)
    .then((resp) => {
      $d.form = resp.data
    })
    .catch((err) => {
      $f.ui.showNotifyFailed($f.getAxiosErrMsg(err))
    })
    .finally(() => {
      loadingState.value = false
    })
}
//region FPS配置
const {
  detailInfo,
  detailStatus,
  detailNav
} = useDetailHelper('/wms/sku/label-management',
  $d.form,
  defFormDataForCreate,
  '/wms/sku/label-management',
  '/wms/sku/label-management/detail',
  null,
  null,
  loadModelData,
  serverErrorMessage
)
const {
  isViewMode,
  isViewOrEditMode,
  pageSubTitle
} = detailStatus



</script>
